/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.financial.entity.declarationnotice;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.modules.base.entity.customer.Customer;
import com.jeesite.modules.base.entity.supplier.Supplier;
import com.jeesite.modules.logistics.entity.customsdeclaration.CustomsDeclaration;
import com.jeesite.modules.logistics.entity.ladingbill.LadingBill;
import com.jeesite.modules.order.entity.serviceorder.ServiceOrder;
import com.jeesite.modules.sys.entity.User;
import org.hibernate.validator.constraints.Length;

import java.util.Date;
import java.util.List;

/**
 * 报关通知Entity
 * @author shengbin
 * @version 2021-03-05
 */
@Table(name="t_customs_declaration_notice", alias="a", columns={
		@Column(name="customs_declaration_notice_id", attrName="customsDeclarationNoticeId", label="报关通知ID", isPK=true),
		@Column(name="customs_declaration_notice_code", attrName="customsDeclarationNoticeCode", label="编号", queryType=QueryType.LIKE),
		@Column(name="is_notice", attrName="isNotice", label="是否通知"),
		@Column(name="customer_id", attrName="customerId", label="客户"),
		@Column(name="service_order_id", attrName="serviceOrderId", label="服务订单"),
		@Column(name="customs_broker", attrName="customsBroker", label="报关行"),
		@Column(name="lading_bill_id", attrName="ladingBillId", label="提单编号"),
		@Column(name="customs_declaration_code", attrName="customsDeclarationCode", label="报关单"),
		@Column(name="to_port", attrName="toPort", label="目的港"),
		@Column(name="foreign_trade_contract_number", attrName="foreignTradeContractNumber", label="外贸合同号"),
		@Column(name="purchase_commission_number", attrName="purchaseCommissionNumber", label="采购委托书号"),
		@Column(name="date", attrName="date", label="通知日期"),
		@Column(name="all_upload_flag", attrName="allUploadFlag", label="已全部上传"),
		@Column(name="create_by", attrName="createBy", label="创建者", isUpdate=false),
		@Column(name="create_date", attrName="createDate", label="创建时间", isUpdate=false),
		@Column(name="update_by", attrName="updateBy", label="更新者", isQuery=false),
		@Column(name="update_date", attrName="updateDate", label="更新时间", isQuery=false),
		@Column(name="remarks", attrName="remarks", label="备注信息", isQuery=false),
	},joinTable={
		@JoinTable(type= JoinTable.Type.LEFT_JOIN, entity= Customer.class, attrName="customer", alias="u12",
				on="u12.customer_id = a.customer_id", columns={
				@Column(name="customer_id", label="客户编码", isPK=true),
				@Column(name="customer_name", label="客户名称", isQuery=false),
		}),
		@JoinTable(type= JoinTable.Type.LEFT_JOIN, entity= Supplier.class, attrName="supplier", alias="sup",
				on="sup.supplier_id = a.customs_broker", columns={
				@Column(name="supplier_id", label="报关行编码", isPK=true),
				@Column(name="supplier_name", label="报关行名称", isQuery=false),
		}),
		@JoinTable(type= JoinTable.Type.LEFT_JOIN, entity= ServiceOrder.class, attrName="serviceOrder", alias="so",
				on="so.service_order_id = a.service_order_id", columns={
				@Column(name="service_order_id", label="服务订单id", isPK=true),
				@Column(name="service_order_code", label="服务订单名称"),
		}),
		@JoinTable(type= JoinTable.Type.LEFT_JOIN, entity= LadingBill.class, attrName="ladingBill", alias="lad",
				on="lad.lading_bill_id = a.lading_bill_id", columns={
				@Column(name="lading_bill_id", label="提单id", isPK=true),
				@Column(name="lading_bill_code", label="提单名称"),
		}),
		@JoinTable(type= JoinTable.Type.LEFT_JOIN, entity= CustomsDeclaration.class, attrName="customsDeclaration", alias="cusdec",
				on="cusdec.customs_declaration_id = a.customs_declaration_code", columns={
				@Column(name="customs_declaration_id", label="报关单id", isPK=true),
				@Column(name="customs_declaration_code", label="报关名称"),
		}),
		@JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = User.class, attrName = "createByUser", alias = "createby",
				on = "createby.user_code = a.create_by", columns = {
				@Column(name = "user_code", label = "用户编码", isPK = true),
				@Column(name = "user_name", label = "用户名称", isQuery = false),
		}),
		@JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = User.class, attrName = "updateByUser", alias = "updateby",
				on = "updateby.user_code = a.update_by", columns = {
				@Column(name = "user_code", label = "用户编码", isPK = true),
				@Column(name = "user_name", label = "用户名称", isQuery = false),
		}),
},orderBy="a.update_date DESC"
)
public class TdeclarationNotice extends DataEntity<TdeclarationNotice> {
	
	private static final long serialVersionUID = 1L;
	private String customsDeclarationNoticeId;		// 报关通知ID
	private String customsDeclarationNoticeCode;		// 编号
	private String isNotice;		// 是否通知
	private String customerId;		// 客户
	private String serviceOrderId;		// 服务订单
	private String customsBroker;		// 报关行
	private String ladingBillId;		// 提单编号
	private String customsDeclarationCode;		// 报关单
	private String toPort;		// 目的港
	private String foreignTradeContractNumber;		// 外贸合同号
	private String purchaseCommissionNumber;		// 采购委托书号
	private Date date;		// 通知日期
	private String allUploadFlag;		// 已全部上传
	private List<TdeclarationNoticeList> tdeclarationNoticeListList = ListUtils.newArrayList();		// 子表列表
	private List<TdeclarationNoticeDetail> tdeclarationNoticeDetailList = ListUtils.newArrayList();		// 子表列表

	private Customer customer;
	private Supplier supplier;
	private ServiceOrder serviceOrder;
	private LadingBill ladingBill;
	private CustomsDeclaration customsDeclaration;
	private User createByUser;
	private User updateByUser;


	public TdeclarationNotice() {
		this(null);
	}

	public TdeclarationNotice(String id){
		super(id);
	}
	
	public String getCustomsDeclarationNoticeId() {
		return customsDeclarationNoticeId;
	}

	public void setCustomsDeclarationNoticeId(String customsDeclarationNoticeId) {
		this.customsDeclarationNoticeId = customsDeclarationNoticeId;
	}
	
	@Length(min=0, max=100, message="编号长度不能超过 100 个字符")
	public String getCustomsDeclarationNoticeCode() {
		return customsDeclarationNoticeCode;
	}

	public void setCustomsDeclarationNoticeCode(String customsDeclarationNoticeCode) {
		this.customsDeclarationNoticeCode = customsDeclarationNoticeCode;
	}
	
	public String getIsNotice() {
		return isNotice;
	}

	public void setIsNotice(String isNotice) {
		this.isNotice = isNotice;
	}
	
	@Length(min=0, max=64, message="客户长度不能超过 64 个字符")
	public String getCustomerId() {
		return customerId;
	}

	public void setCustomerId(String customerId) {
		this.customerId = customerId;
	}
	
	@Length(min=0, max=64, message="服务订单长度不能超过 64 个字符")
	public String getServiceOrderId() {
		return serviceOrderId;
	}

	public void setServiceOrderId(String serviceOrderId) {
		this.serviceOrderId = serviceOrderId;
	}
	
	@Length(min=0, max=64, message="报关行长度不能超过 64 个字符")
	public String getCustomsBroker() {
		return customsBroker;
	}

	public void setCustomsBroker(String customsBroker) {
		this.customsBroker = customsBroker;
	}
	
	@Length(min=0, max=64, message="提单编号长度不能超过 64 个字符")
	public String getLadingBillId() {
		return ladingBillId;
	}

	public void setLadingBillId(String ladingBillId) {
		this.ladingBillId = ladingBillId;
	}
	
	@Length(min=0, max=100, message="报关单长度不能超过 100 个字符")
	public String getCustomsDeclarationCode() {
		return customsDeclarationCode;
	}

	public void setCustomsDeclarationCode(String customsDeclarationCode) {
		this.customsDeclarationCode = customsDeclarationCode;
	}
	
	@Length(min=0, max=2, message="目的港长度不能超过 2 个字符")
	public String getToPort() {
		return toPort;
	}

	public void setToPort(String toPort) {
		this.toPort = toPort;
	}
	
	@Length(min=0, max=100, message="外贸合同号长度不能超过 100 个字符")
	public String getForeignTradeContractNumber() {
		return foreignTradeContractNumber;
	}

	public void setForeignTradeContractNumber(String foreignTradeContractNumber) {
		this.foreignTradeContractNumber = foreignTradeContractNumber;
	}
	
	@Length(min=0, max=100, message="采购委托书号长度不能超过 100 个字符")
	public String getPurchaseCommissionNumber() {
		return purchaseCommissionNumber;
	}

	public void setPurchaseCommissionNumber(String purchaseCommissionNumber) {
		this.purchaseCommissionNumber = purchaseCommissionNumber;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd")
	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}
	
	@Length(min=0, max=1, message="已全部上传长度不能超过 1 个字符")
	public String getAllUploadFlag() {
		return allUploadFlag;
	}

	public void setAllUploadFlag(String allUploadFlag) {
		this.allUploadFlag = allUploadFlag;
	}

	public Date getDate_gte() {
		return sqlMap.getWhere().getValue("date", QueryType.GTE);
	}

	public void setDate_gte(Date date) {
		sqlMap.getWhere().and("date", QueryType.GTE, date);
	}

	public Date getDate_lte() {
		return sqlMap.getWhere().getValue("date", QueryType.LTE);
	}

	public void setDate_lte(Date date) {
		sqlMap.getWhere().and("date", QueryType.LTE, date);
	}

	public Date getCreateDate_gte() {
		return sqlMap.getWhere().getValue("create_date", QueryType.GTE);
	}

	public void setCreateDate_gte(Date createDate) {
		sqlMap.getWhere().and("create_date", QueryType.GTE, createDate);
	}
	
	public Date getCreateDate_lte() {
		return sqlMap.getWhere().getValue("create_date", QueryType.LTE);
	}

	public void setCreateDate_lte(Date createDate) {
		sqlMap.getWhere().and("create_date", QueryType.LTE, createDate);
	}
	
	public List<TdeclarationNoticeList> getTdeclarationNoticeListList() {
		return tdeclarationNoticeListList;
	}

	public void setTdeclarationNoticeListList(List<TdeclarationNoticeList> tdeclarationNoticeListList) {
		this.tdeclarationNoticeListList = tdeclarationNoticeListList;
	}
	
	public List<TdeclarationNoticeDetail> getTdeclarationNoticeDetailList() {
		return tdeclarationNoticeDetailList;
	}

	public void setTdeclarationNoticeDetailList(List<TdeclarationNoticeDetail> tdeclarationNoticeDetailList) {
		this.tdeclarationNoticeDetailList = tdeclarationNoticeDetailList;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public Supplier getSupplier() {
		return supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}

	public ServiceOrder getServiceOrder() {
		return serviceOrder;
	}

	public void setServiceOrder(ServiceOrder serviceOrder) {
		this.serviceOrder = serviceOrder;
	}

	public LadingBill getLadingBill() {
		return ladingBill;
	}

	public void setLadingBill(LadingBill ladingBill) {
		this.ladingBill = ladingBill;
	}

	public CustomsDeclaration getCustomsDeclaration() {
		return customsDeclaration;
	}

	public void setCustomsDeclaration(CustomsDeclaration customsDeclaration) {
		this.customsDeclaration = customsDeclaration;
	}

	public User getCreateByUser() {
		return createByUser;
	}

	public void setCreateByUser(User createByUser) {
		this.createByUser = createByUser;
	}

	public User getUpdateByUser() {
		return updateByUser;
	}

	public void setUpdateByUser(User updateByUser) {
		this.updateByUser = updateByUser;
	}
}